package cn.demo.cm.domain;

import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import cn.demo.common.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cn.demo.common.core.domain.BaseEntity;
/**
 * 举报投诉对象 cm_complaint
 *
 * @author xtjun
 * @date 2024-06-04
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "cm_complaint",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class CmComplaint extends BaseEntity {
    private static final long serialVersionUID = 1L;

    @Id
    @Schema(description = "主键")
    private String id;

    @Excel(name = "用户id")
    @Schema(description = "用户id")
    private String userId;

    @Excel(name = "姓名")
    @Schema(description = "姓名")
    @NotBlank(message = "姓名不能为空")
    private String name;

    @Excel(name = "电话")
    @Schema(description = "电话")
    @NotBlank(message = "电话不能为空")
    private String phone;

    @Excel(name = "图片")
    @Schema(description = "图片")
    @NotBlank(message = "图片不能为空")
    private String pic;

    @Excel(name = "内容")
    @Schema(description = "内容")
    @NotBlank(message = "内容不能为空")
    private String content;

    @Excel(name = "回复")
    @Schema(description = "回复")
    private String reply;

    @Excel(name = "是否处理", dictType = "sys_yes_no")
    @Schema(description = "是否处理(字典:sys_yes_no)")
    private Integer isHandle;

    @Excel(name = "处理人")
    @Schema(description = "处理人")
    private String handleUser;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "处理时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "处理时间")
    private LocalDateTime handleTime;

    @Excel(name = "部门id")
    @Schema(description = "部门id")
    private String deptId;

    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = new SqlOperators() {{
        set(CmComplaint::getUserId, SqlOperator.EQUALS);
        set(CmComplaint::getName, SqlOperator.LIKE);
        set(CmComplaint::getPhone, SqlOperator.EQUALS);
        set(CmComplaint::getIsHandle, SqlOperator.EQUALS);
        set(CmComplaint::getHandleUser, SqlOperator.LIKE);
        set(CmComplaint::getDeptId, SqlOperator.EQUALS);
    }};
}
